<!DOCTYPE html>
<html style="background:#fff">

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
	<title>申请提现</title>
	<link rel="stylesheet" type="text/css" href="../../css/api.css" />
	<link rel="stylesheet" type="text/css" href="./css/my.css" />
</head>

<body style="background:#fff">
	<div class="widthdraw_bg">
		<img src="./image/withdraw_bg.png" />
		<div class="withdrawTitles">
			<label>我的余额</label>
			<span>￥<em class="balance"></em></span>
		</div>
		<div class="withdraw_help">
			<div class="withdraw_record">
				<span onclick="goTosettlement()">结算记录</span>
				<img src="./image/problem.png" />
			</div>
			<div class="widthdrwa_rule">规则</div>
		</div>
		<!--<div class="w_paycode" tapmode onclick="openWinto('user_shoukuanma_win','widget://html/coupon_head',{url:'widget://html/my/shoukuanma.html',name:'我的收款码',islogin:true})">设置我的收款码</div>-->
	</div>
	<div class="widthdraw_content">
		<div class="widthdraw_title">选择提现金额（最小提现<span class="mincash"></span> 元，税费<span class="rate"></span>%）</div>
		<div class="widthdraw_input">
			<span>￥</span>
			<input type="number" disabled='disabled' style="font-size:22px;color:#fd3d38;" class="widthdraw_inp" placeholder="输入你的提现金额">
		</div>
		<div onclick="doWithdraw()" class="withdrawal_btn">确认提现</div>
	</div>

	<!--提现弹框-->
	<div class="withdrawal_box" style="display:none">
		<div class="widthdraw_item">
			<div class="withdrawal_contents">
				<div class="withdraw_icon">
					<img src="./image/w_icon.png" />
				</div>
				<div class="withdraw_success">提现成功</div>
				<div class="widthdraw_jd">提现金额将在1个工作日内到账</div>
				<div class="widthdraw_btn_jd" tapmode onclick="openWinto('user_commission_win','widget://html/coupon_head',{url:'widget://html/my/commission.html',name:'余额记录',islogin:true})">查看进度</div>
			</div>
			<div class="widthdraw_close"><img src="./image/guanbi.png" /></div>
		</div>
	</div>
	<!--提现规则-->
	<div class="pay_style_box" style="display: none">
		<div class="pay_style_content">
			<div class="pay_style_c">
				<div class="pay_style_titles">提现规则</div>
				<div class="poster_rule_content">
					1.淘宝每月25日后均可提现上月已结算订单。<br> 2.京东每月25日后均可提现上月已结算订单。
					<br> 3.拼多多每月25日后均可提现当月16日前已结算订单。
					<br></div>
			</div>
			<div class="widthdraw_close"><img src="./image/guanbi.png"></div>
		</div>
	</div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/config.js"></script>
<script type="text/javascript" src="../../script/zepto.min.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>

<script type="text/javascript">
	var appset = {};
	var userinfo = {};
	apiready = function() {
		getmemberinfo();
		initclick();
		getAppset();
	};

	function getmemberinfo() {
		userinfo = isLogin();
		if (userinfo) {
			$('.balance').html((userinfo.user_money * 1).toFixed(2));
			$('.widthdraw_inp').val((userinfo.user_money * 1).toFixed(2));
		}
	}

	function getAppset() {
		postData(API_URL + 'getAppset', {}, function(ret) {
			if(ret.code==1){
				appset = ret.data;
				$('.mincash').html(ret.data.mincash);
				$('.rate').html(ret.data.rate);
			}else{
				showToast(TipInfo.data_busy);
			}
		})
	}

	function doWithdraw() {
		var data = new Object();
		if (parseFloat(userinfo.user_money) < parseFloat(appset.mincash)) {
			showToast('最小提现金额为' + appset.mincash + '元');
			return;
		}
		/*
		if (!userinfo.wechart_income_code) {
			showToast('请先设置收款码后再提现吧!');
			return;
		}
		*/

		if (parseFloat(userinfo.user_money) <= 0) {
			showToast('提现金额不能为0元!');
			return;
		}

		postDataLogin('getTiXian', {
			'money': userinfo.user_money
		}, function(ret, err) {
			if (ret.code == 1) {
				$(".withdrawal_box").show();
				$(".widthdraw_close").click(function() {
					$(".withdrawal_box").hide();
					var jsfun = 'location.reload();';
					$api.setStorage('my_click', 1);
					api.execScript({
						name: 'root',
						frameName: 'my_win',
						script: jsfun
					});
					api.closeWin({
						name: 'user_withdraw_win'
					});
				});
			} else {
				showToast(ret.msg);
			}
		});

	}

	function initclick() {

		$(".widthdrwa_rule").click(function() {
			$(".pay_style_box").show();
		});
		$(".widthdraw_close").click(function() {
			$(".pay_style_box").hide();
		});

	}

	function goTosettlement() {
		openWinto('user_commission_win', 'widget://html/coupon_head', {
			url: 'widget://html/my/commission.html',
			name: '余额记录',
			islogin: true
		});
	}
</script>

</html>
